package edu.hziee.controller;

import java.io.IOException;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/myupload")
public class MyuploadController {

	@RequestMapping(method=RequestMethod.GET)
	public ModelAndView get(){
		ModelAndView mav = new ModelAndView("myupload");
		return mav;
	}
	
	@RequestMapping(method=RequestMethod.POST)
	public ModelAndView post(@RequestParam String date, @RequestParam MultipartFile file){
		
		try {
			byte[] bytes = file.getBytes();
			System.out.println(bytes);
		} catch (IOException e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		
		ModelAndView mav = new ModelAndView("myupload");
		return mav;
	}
}
